import { Injectable } from "@nestjs/common";

@Injectable()
export class ProductService{
 private products=[
        {
            id:1,
            name:"无线鼠标",
            price:99,
            stock:100
        },
        {
            id:2,
            name:"机械键盘",
            price:299,
            stock:50
        },

    ];

    //获取所有商品信息
    getAllProducts(){
        return this.products
    }
    //根据id获取商品
    getProductById(id:number){
        return this.products.find(product=>product.id===id)
    }

}